package com.scwatch.ext.domain;

import com.scwatch.core.domain.Site;
import com.scwatch.core.domain.User;
import com.scwatch.core.support.Siteable;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "start_page", schema = "cms4", catalog = "")
public class StartPage  implements java.io.Serializable,Siteable {
    private Integer id;
    private String name;//
    private Site site;
    private User user;
    private Date createTime;
    private String isStart;//
    private String modifyTime;//
    private String pictureUrl;//
    private String type;
    private Date startTime;
    private Date endTime;
    private Integer sort;//
    private String relateNews;   //f_relate_news 关联新闻

    @Transient
    private List<String> newsUrl;   //f_relate_news 关联新闻


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "site_id", nullable = false)
    public Site getSite() {
        return site;
    }

    public void setSite(Site site) {
        this.site = site;
    }

    @Column(name = "f_relate_news", length = 1000)
    public String getRelateNews() {
        return relateNews;
    }

    public void setRelateNews(String relateNews) {
        this.relateNews = relateNews;
    }

    @Id
    @Column(name = "id", unique = true, nullable = false)
    @TableGenerator(name = "tg_start_page", pkColumnValue = "start_page", initialValue = 1, allocationSize = 10)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_start_page")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = true, length = 50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "is_start", nullable = true, length = 11)
    public String getIsStart() {
        return isStart;
    }

    public void setIsStart(String isStart) {
        this.isStart = isStart;
    }

    @Basic
    @Column(name = "modify_time", nullable = true, length = 50)
    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    @Basic
    @Column(name = "picture_url", nullable = true, length = 50)
    public String getPictureUrl() {
        return pictureUrl;
    }

    public void setPictureUrl(String pictureUrl) {
        this.pictureUrl = pictureUrl;
    }

    @Basic
    @Column(name = "type", nullable = true, length = 10)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Basic
    @Column(name = "start_time", nullable = true)
    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    @Basic
    @Column(name = "end_time", nullable = true)
    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    @Basic
    @Column(name = "sort", nullable = true)
    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        StartPage startPage = (StartPage) o;

        if (id != startPage.id) return false;
        if (name != null ? !name.equals(startPage.name) : startPage.name != null) return false;
        if (createTime != null ? !createTime.equals(startPage.createTime) : startPage.createTime != null) return false;
        if (isStart != null ? !isStart.equals(startPage.isStart) : startPage.isStart != null) return false;
        if (modifyTime != null ? !modifyTime.equals(startPage.modifyTime) : startPage.modifyTime != null) return false;
        if (pictureUrl != null ? !pictureUrl.equals(startPage.pictureUrl) : startPage.pictureUrl != null) return false;
        if (type != null ? !type.equals(startPage.type) : startPage.type != null) return false;
        if (startTime != null ? !startTime.equals(startPage.startTime) : startPage.startTime != null) return false;
        if (endTime != null ? !endTime.equals(startPage.endTime) : startPage.endTime != null) return false;
        if (sort != null ? !sort.equals(startPage.sort) : startPage.sort != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (isStart != null ? isStart.hashCode() : 0);
        result = 31 * result + (modifyTime != null ? modifyTime.hashCode() : 0);
        result = 31 * result + (pictureUrl != null ? pictureUrl.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
        result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
        result = 31 * result + (sort != null ? sort.hashCode() : 0);
        return result;
    }
    @Transient
    public List<String> getNewsUrl() {
        return newsUrl;
    }
    @Transient
    public void setNewsUrl(List<String>  newsUrl) {
        this.newsUrl = newsUrl;
    }
}
